home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / dosbasic.zip / ASM.ZIP / NOPRINT.ASM < prev    next >
Assembly Source File  |  1990-12-19  |  5KB  |  131 lines

  1. ;«RM82»«TS8,16,24,32,40,48,56,64»
  2. ; updated 11/20/90
  3.  
  4. ;============================================================================
  5. ;   Copyright (C) Copr. 1990 by Sidney J. Kelly
  6. ;                   All Rights Reserved.
  7. ;           Sidney J. Kelly
  8. ;           150 Woodhaven Drive
  9. ;           Pittsburgh, PA 15228
  10. ;           home phone 412-561-0950 (7pm to 9:30pm EST)
  11. ;============================================================================
  12.  
  13. DOSSEG
  14. .MODEL MEDIUM
  15.     PUBLIC PRINTSCREEN, KILLPRINT
  16.  
  17. .CODE
  18.  
  19. ; Please do not remove
  20. Copyright       DB    13,10,'Copyright Copr. (C) 1990 Sidney J. Kelly',13,10
  21. Copyright1      DB    'All Rights Reserved',13,10,26
  22.  
  23. ;============================================================================
  24. ; DECLARE SUB PRINTSCREEN%(Mode%, Error%)
  25. ; IF Error% THEN
  26. ;       printer error
  27. ; else
  28. ;       all o.k.
  29. ; end if
  30. ;
  31. ; Input:  0 = turn off printscreen key
  32. ;         1 = printscreen, then shut down key again
  33. ; Prints to LPT1
  34. ;============================================================================
  35.  
  36. EVEN
  37. Installed    db    0
  38.  
  39. EVEN
  40. PRINTSCREEN     PROC    FAR
  41.     Push    BP                      ; save stack frame
  42.     Mov     BP,SP
  43.     Mov     BX,[BP+8]               ; get address of mode
  44.     Mov     BX,[BX]                 ; read value of mode
  45.     Xor     AX,AX                   ; set ES to BIOS RAM
  46.     Mov     ES,AX
  47.     Or      BX,BX                   ; is mode zero?
  48.     JZ      No_Print                ; yep, so skip ahead
  49.  
  50. Print:
  51.     Xor    DX,DX            ; select LPT1 or PRN
  52.     Mov     AH, 2                   ; Check printer status for
  53.     Int     17h                     ; Printer bios interrupt
  54.         TEST    AH, 00101001b           ; Are any error bits on?
  55.     JNE     Error_Exit              ; Yes?  Error so exit
  56.     TEST    AH, 10010000b           ; Are both operation bits on?
  57.     JZ      Error_Exit              ; No?  Error so exit
  58.     Jmp    Short  BeginPrint       ; o.k. so try and print
  59.  
  60. Error_Exit:
  61.     Mov    AX,-1                   ; return error
  62.     Jmp    Short  No_Print        ; turn off print screen
  63.  
  64. BeginPrint:                             ; No Errors
  65.     Cmp    Installed,1              ; have we done this before
  66.     JE    No_EGA                  ; if yes then skip ahead
  67.     Mov    Installed,1             ; note that we are installed
  68.     Mov     AH,12h                  ; EGA BIOS EGA special function;
  69.                     ; service
  70.     Mov     BL,10h                  ; request EGA info
  71.     Int     10h                     ; call the BIOS
  72.     CMP     BL,10h                  ; if BL is still 10h, no EGA
  73.     JZ      No_EGA                  ; if no EGA so skip ahead
  74.  
  75. Select_Alt_Prnscrn:
  76.     Mov     AX,1200h                ; select printscreen function
  77.     Mov     BX,29h                  ; that understands screens other
  78.     Int     10h                     ; other than 80 x 25
  79.  
  80. No_EGA:
  81.     Mov     Byte PTR ES:[0500h],0h  ; tell RAM BIOS not busy, no error
  82.     Push    BP                      ; (per Leading Edge MS-DOS reference)
  83.     Int     5h                      ; do a print screen
  84.     Pop    BP                      ; (--must save BP)
  85.         Xor    AX,AX                   ; report no error
  86.  
  87. No_Print:
  88.     Mov     Byte PTR ES:[0500h],01h ; tell RAM BIOS function is busy
  89.     Mov    BX,[BP+6]               ; report back error
  90.         Mov    [BX],AX                 ; if any
  91.     Pop     BP                      ; restore stack
  92.     Ret     4            ; remove 2*2 parameters
  93. PRINTSCREEN     ENDP
  94.  
  95. ;============================================================================
  96. ; DECLARE SUB KILLPRINT (LptNum%)
  97. ;       CALL KILLPRINT(LptNum%)
  98. ;
  99. ; Halts LptNum%, by resetting and purging buffer. Printer reset to defaults
  100. ; all non-default formats lost.  Will do nothing if errors noted, printer
  101. ; is not busy.
  102. ;============================================================================
  103.  
  104. EVEN
  105. KILLPRINT   PROC    FAR
  106.     Push    BP                      ; address stack
  107.     Mov     BP,SP
  108.     Mov     BX,[BP+6]
  109.     Mov     DX,[BX]                 ; get printer number in DX
  110.     Dec     DX                      ; make it zero biased
  111.     Cmp     DX,4                    ; make sure Lpt# is 0 to 3
  112.     JB      @f                      ;
  113.     Xor     AX,AX                   ; if out of range make it LPT1:
  114. @@:
  115.     Mov     AH, 2                   ; First, check printer status for
  116.     Int     17h                     ; Printer bios interrupt
  117.     TEST    AH, 00101001b           ; Are any error bits on?
  118.     JNZ     Exit1                   ; Yes?  Error so exit because already
  119.                     ; halted.
  120.     TEST    AH, 80h                 ; is printer busy (bit 7 Clear)
  121.     JNZ     Exit1                   ; nope, bit set, printer not busy
  122.                     ; so quit, nothing to stop
  123.     Mov     AH,1                    ; resets the printer to default
  124.     Int     17h
  125.  
  126. Exit1:
  127.     Pop     BP
  128.     Ret     2                       ; remove 1 * 2 parameters
  129. KILLPRINT   ENDP
  130. END
  131.